/**
 * 扬尘设备配置（添加|修改）dustProCheckPointOption.js
 * 版本号： v1.0.0
 */
$(function(){

    //限制字段输入长度
    limitFieldLength();

    //所属项目绑定
    bindCombo_projectSel("prId");

    //操作按钮点击
    $('#optionDustProCheckPoint').bind('click', function(){
        var params = $("#dustProCheckPoint_form").serialize();
        $("#dustProCheckPoint_form").form("submit",{
            cache:false,
            data: params,
            url: CONTEXT_PATH + "/dustProCheckPoint/save.do",
            onSubmit:function() {
                preventSubmit('dustProCheckPoint_form','optionDustProCheckPoint');
                return $(this).form("validate");
            },
            success:function(data) {
                var obj = JSON.parse(data);
                var url = null;
                if(source == "deviceManage"){
                    url = CONTEXT_PATH + "/device/index.do";
                }else{
                    url = CONTEXT_PATH + "/dustProCheckPoint/index.do";
                }
                saveJump(obj,url);
            }
        });
    });

});

/**
 * 所属项目bind事件
 * @param deviceControl
 */
function bindCombo_projectSel(projectControl){
    $.ajax({
        url: CONTEXT_PATH + "/project/getProjectListForCombo.do",
        type: "get",
        success: function (data) {
            var obj = JSON.parse(data);
            var projectCombo = [{'text': '--请选择--','value': ''}];
            for (var i = 0; i < obj.length; i++) {
                projectCombo.push({"text": obj[i].prName, "value": obj[i].prId});
            }
            $("#" + projectControl).combobox("loadData", projectCombo);
            $("#" + projectControl).combobox({
                required:true,
                onSelect: function(rec){
                    $('#prId_').val(rec.value);
                }
            });
            var prId = $('#prId_').val();
            if(prId){
                $("#" + projectControl).combobox("setValue", prId);
            }else{
                $("#" + projectControl).combobox("setValue", '');
            }

        }
    })
}

